package priv.lirenhe.dissertation.data_generator;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import priv.lirenhe.dissertation.component.search_engine.search_engine_executor.SearchEngineExecutor;
import priv.lirenhe.dissertation.executor.ComponentsExecutor;

public class DataHtml {
	
	
	public static List<String> getQueryData(String queryStr,int pageIndex){
		
		String webPageRealurl = null;
		String webPageTitle = null;
		List<String> list_Value = new ArrayList<String>();
		
		List<Map<String,String>> list_map_Value = null;
		list_map_Value = ComponentsExecutor.getSearcherResult(queryStr, pageIndex);
		
		if(list_map_Value != null && !list_map_Value.isEmpty()){
			for(Map<String,String> map_Value : list_map_Value){
				
				webPageRealurl = map_Value.get("webPageRealurl");
				webPageTitle = map_Value.get("webPageTitle");
				
				String html_Data = "<a href='"+webPageRealurl+"'>"+webPageTitle+"</a>";
				list_Value.add(html_Data);
			}
			
		}
		return list_Value;
	}
	
	public static void main(String[] args) {
		List<String> list_Value = null;
		list_Value = DataHtml.getQueryData("亚马逊", 1);
		if(list_Value != null && !list_Value.isEmpty()){
			for(String str:list_Value){
				System.out.println(str);
			}
		}else{
			System.out.println("没有检索到");
		}
	}
}
